package com.sanctity.controller;

import com.sanctity.domain.Order;
import com.sanctity.service.OrderService;
import com.sanctity.vo.OrderUserVo;
import com.sanctity.vo.OrderVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.math.BigDecimal;

/***
 * @belongsProject spring-cloud
 * @description <TODO description class purpose>
 * @author Sanct
 * @version 1.0.0
 * @create 2024/1/16 22:09
 **/

@RestController
@RequestMapping("/order")
public class OrderController {

    @Autowired
    private OrderService orderService;

    @GetMapping("/{id}")
    public OrderUserVo findOrderDetailById(@PathVariable Integer id){
        return orderService.findWithUserById(id);
    }

    @GetMapping("/add/{id}")
    public OrderVo addOrder(@PathVariable Integer id){
        Order order = new Order();
        order.setName(" Apple 苹果手机 "+ id + "Pro");
        order.setUserId(new Long(id));
        order.setNum(1);
        order.setPrice(new BigDecimal(8000));
        OrderVo orderVo = orderService.addOrder(order);
        return orderVo;
    }

}
